﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kunlun.Models;
namespace Kunlun.BusinessLogic {
	
	public class KunlunLibrary {
		public static List<Consumer_library> GetLibrary(int uid) {
			KunLunEntities entities = new KunLunEntities();
			return entities.Consumer_library.Where(o => o.UserID == uid && o.IsVisible).ToList();
		}

		public static List<Consumer_pic> GetPic(int dirID, int index, int size,int width,int height,out int count) {
			KunLunEntities entities = new KunLunEntities();
			IQueryable<Consumer_pic> query = entities.Consumer_pic.Where(o => o.Library == dirID && o.Status == 1 && o.Width > width && o.Height > height).OrderBy(o => o.BeginDate);
			count = query.Count();
			if (index != 0) {
				query = query.Skip(index * size);
			}
			if (size != 0) {
				query = query.Take(size);
			}
			return query.ToList();
		}
	}
}
